<link rel="stylesheet" type="text/css" href="<?php echo base_url('skin/css/admin.css');?>" />

<?php if (isset($action) && ($action==='list')):?>
<!-- List Of Ranges  -->
<div id="lists">
    <table>
        <thead>
            <tr>
                <th>Welcome <?php echo $this->session->userdata("user_account_name");?> <a href="<?php echo site_url('user/logout')?>">Logout</a></th>
                <th><a href="<?php echo site_url('user')?>">Users List</a></th>
                <th><a href="<?php echo site_url('price_range')?>">Price Range</a></th>
                <th><a href="<?php echo site_url('user/changePassword')?>">Change Password</a></th>
            </tr>
        </thead>
    </table>
    <br />

    <table border="0" cellpadding="0" cellspacing="0" class="borderless">
        <thead>
            <tr>
                <th><div><b>Price Range</b></div></th>
                <th></th>
                <th></th>
            </tr>
        </thead>
    </table>
    <?php if ($this->session->flashdata('success')): ?>
    <table border="0" cellpadding="0" cellspacing="0" class="borderless">
        <thead>
            <tr>
                <th><div><?php echo $this->session->flashdata('success');?></div></th>
            </tr>
        </thead>
    </table>
    <?php endif; ?>
    <?php if ($this->session->flashdata('error')): ?>
    <table border="0" cellpadding="0" cellspacing="0" class="borderless">
        <thead>
            <tr>
                <th><div class="error"><?php echo $this->session->flashdata('error'); ?></div></th>
            </tr>
        </thead>
    </table>
    <?php endif; ?>
    
    <table>
        <thead>
            <tr>
                <th>Min</th>
                <th>Max</th>
                <th>Action</th>
            </tr>
        </thead>
  
        <tbody>
            <?php foreach($price_range as $key => $data) : ?>
            <?php
                $id = urlencode(base64_encode($data->id));
            ?>
            <tr>
                <td><?php echo $data->min;?></td>
                <td><?php echo $data->max;?></td>
                <td><a href="<?php echo site_url('price_range/edit/'.$id)?>">Edit</a>/
                    <a href="<?php echo site_url('price_range/delete/'.$id)?>">Delete</a></td>
            </tr>
            <?php endforeach; ?>
        </tbody>  
        <tfoot>
            <tr>
                <td colspan="3" align="center">
                    <a href="<?php echo site_url('price_range/edit')?>">Add</a>
                </td>
           </tr>
        </tfoot>
    </table>
</div>

<?php else: ?>
<!-- Add/Edit Range  -->
<div class="formedit" id="frm_pricerange">
    <span class="w100px">Prince Range</span>
    <fieldset>
        <form id="frm_resetpass" method="POST" action="<?php echo site_url('price_range/save')?>">
            <input type="hidden" name="id" value="<?php echo isset($id)?$id:'';?>" /><br>
            <span class="w100px">Min:</span>
            <input type="text" name="min" maxlength="5" value="<?php echo isset($id)?$data->min:''; ?>"/><br>
            <span class="w100px">Max:</span>
            <input type="text" name="max" maxlength="5" value="<?php echo isset($id)?$data->max:''; ?>"/><br>
            <br><br>
            <input type="submit" value="Submit" /><input type="reset" class="reset" value="Reset" /><br />
            <a href="<?php echo site_url("price_range")?>">Back</a>
        </form>

    </fieldset>
</div>
<?php endif; ?>